<template>
  <div class="order-item-container">
    <div class="item">
      <div class="item-top">
        <div class="item-top-left" v-if="info?.cinemaName">
          <span class="item-top-left-title">{{ info?.cinemaName }} </span>
          <span class="iconfont icon-jinrujiantou1 size"></span>
        </div>

        <div class="item-top-right" v-if="info?.orderProgress == 0">
          <div
            v-if="
              info?.createTime &&
              new Date().getTime() <=
                new Date(info?.createTime).getTime() + 5 * 60 * 1000
            "
            style="margin-right: 5px"
          >
            <nut-countdown
              :startTime="new Date().getTime()"
              :endTime="new Date(info?.createTime).getTime() + 5 * 60 * 1000"
              @on-end="TimerOver(info)"
              :time="time"
            ></nut-countdown>
          </div>
          <div
            v-if="
              new Date().getTime() >
              new Date(info?.createTime).getTime() + 5 * 60 * 1000
            "
          >
            订单超时
          </div>
          <div v-else>待支付</div>
        </div>
        <!-- <div class="item-top-right" v-if="info?.orderProgress == 1">受理中</div> -->
        <!-- <div class="item-top-right" v-if="info?.orderProgress == 2">待出票</div> -->
        <div class="item-top-right" v-if="info?.orderProgress == 3">已出票</div>
        <div class="item-top-right" v-if="info?.orderProgress == -1">
          已超时
        </div>
        <div class="item-top-right" v-if="info?.orderProgress == -2">
          出票失败
        </div>
        <div class="item-top-right" v-if="info?.orderProgress == 4">已完成</div>
        <div class="item-top-right" v-if="info?.orderProgress == 1">已支付</div>
      </div>
      <div class="item-data">
        <div class="item-data-image">
          <image
            v-if="info?.moviePoster"
            :src="info?.moviePoster"
            style="width: 75px; border-radius: 4px"
            mode="widthFix"
          ></image>
        </div>
        <div class="item-data-right">
          <div class="item-data-right-camera" v-if="info?.movieName">
            {{ info?.movieName }}
          </div>

          <div class="item-data-right-time" v-if="info?.startTime">
            <div class="item-data-right-time1">
              {{ formatShowTimeYear(info?.startTime) }}
            </div>
            <div class="item-data-right-time2">
              {{ formatShowTime(info?.startTime) }} 开场
            </div>
          </div>
          <div class="item-data-right-hall" v-if="info?.hallName">
            {{ info?.hallName }}
          </div>
          <div class="item-data-right-seat">
            <div
              class="item-data-right-seat-item"
              v-for="(seat, index) in info?.seatData"
              :key="index"
            >
              <template v-if="seat?.edit_position_seat">
                {{ seat?.edit_position_seat }}
              </template>
              <template v-else>
                {{ seat?.seatNo }}
              </template>
            </div>
          </div>
        </div>
        <div class="item-data-price">
          <div class="item-data-price-total" v-if="info?.ticketNum">
            共{{ info?.ticketNum }}张
          </div>
          <div class="item-data-price-number">
            <span>￥</span>
            <span v-if="info?.isQuick == 0">{{ info?.normalPayAmount }}</span>
            <span v-if="info?.isQuick == 1">{{ info?.quickPayAmount }}</span>
          </div>
        </div>
      </div>
      <div class="item-data-footer">
        <div class="item-data-footer-font"></div>
        <div class="item-data-footer-font-btn">
          <div
            v-if="
              info?.orderProgress == 0 &&
              new Date().getTime() <=
                new Date(info?.createTime).getTime() + 5 * 60 * 1000
            "
            class="item-data-footer-font-btn1"
          >
            <nut-button
              color="linear-gradient(to right, #ff6034, #ee0a24)"
              size="small"
              @click="skipPay"
              >去付款</nut-button
            >
          </div>

          <div v-else class="item-data-footer-font-btn2">
            <nut-button
              plain
              type="default"
              size="small"
              style="border: 1px solid #eee"
              @click="handleClickitem"
              >订单详情</nut-button
            >
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { reactive, toRefs, computed, ref } from "vue";
import { Empty } from "@nutui/nutui-taro";
import Taro from "@tarojs/taro";
import TimerCom from "../../components/timer/index.vue";
import moment from "moment";
const formatShowTimeYear = computed(() => {
  return (str) => {
    return moment(str).format("YYYY-MM-DD");
  };
});
// 【格式化】开场时间
const formatShowTime = computed(() => {
  return (str) => {
    return moment(str).format("HH:mm");
  };
});
const TimeFlag = computed(() => {
  return (str) => {
    new Date().getTime() <= new Date(str).getTime() + 5 * 60 * 1000;
  };
});
const props = defineProps({
  info: Object,
});
const { info } = toRefs(props);
const TimerOver = (e) => {
  console.log("时间结束");
  console.log(e, "----------------");
  e.orderProgress = -1;
};
const handleClickitem = () => {
  console.log(info.value.id, "----");
  // return;
  Taro.navigateTo({
    url: `/pages/zhifu-detail/index?orderId=${info.value.id}`,
  });
};
const skipPay = () => {
  console.log(info.value.id, "----");
  // return;
  Taro.navigateTo({
    url: `/pages/order-detail/index?id=${info.value.id}`,
  });
};
const djsFlag = ref(true);
</script>
<style lang="scss">
.order-item-container {
  border-radius: 25px;
  padding: 25px;
  box-shadow: 0 0 3px 3px #f6f8f9;
  background-color: #fff;
  .size {
    font-size: 30px;
  }
  .item {
    box-sizing: border-box;
    .item-top {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
      font-size: 30px;
      padding-bottom: 20px;
      border-bottom: 1px solid #eee;
      .item-top-left {
        display: flex;
        justify-content: space-between;
        align-items: center;
        color: #858a99;
        .item-top-left-title {
          // min-width: 300px;
          display: -webkit-box;
          /* autoprefixer: ignore next */
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 1;
          text-overflow: ellipsis;
          overflow: hidden;
          font-size: 24px;
        }

        .size {
          font-size: 30px;
          font-weight: 700;
        }
      }
      .item-top-right {
        color: #858a99 !important;
        font-size: 24px;
        display: flex;
        justify-content: center;
        align-items: center;

        .nut-countdown__content {
          color: #ee0a24 !important;
          font-size: 24px;
        }
      }
    }
    .item-data {
      display: flex;
      justify-content: flex-start !important;
      margin-top: 15px;
      font-size: 24px;
      position: relative;
      color: #15181d;
      .item-data-image {
        image {
          display: block;
        }
      }
      .item-data-right {
        margin-left: 20px;
        .item-data-right-seat {
          margin-top: 10px;
          display: flex;
          flex-wrap: wrap;

          .item-data-right-seat-item {
            word-wrap: normal;
          }
          .item-data-right-seat-item:nth-child(n + 2) {
            margin-left: 5px;
          }

          display: flex;
          justify-content: flex-start;
          align-items: center;
          color: #858a99;
        }
        .item-data-right-camera {
          font-weight: 700;
          margin-top: 10px;
          font-size: 30px;
          display: -webkit-box;
          /* autoprefixer: ignore next */
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 1;
          text-overflow: ellipsis;
          overflow: hidden;
        }
        .item-data-right-time {
          color: #858a99;
          margin-top: 10px;
          display: flex;
          // justify-content: center;
          align-items: center;
          .item-data-right-time1 {
          }
          .item-data-right-time2 {
            color: #ee0a24;
            margin-left: 8px;
            font-size: 24px;
          }
        }
        .item-data-right-hall {
          color: #858a99;
          margin-top: 10px;
          width: 300px;
          display: -webkit-box;
          /* autoprefixer: ignore next */
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 1;
          text-overflow: ellipsis;
          overflow: hidden;
        }
      }
      .item-data-price {
        display: flex;

        position: absolute;
        right: 25px;
        top: 75px;
        justify-content: center;
        flex-direction: column;
        align-items: center;
        .item-data-price-total {
          font-size: 24px;
          color: #858a99;
        }
        .item-data-price-number {
          display: flex;
          justify-content: center;
          align-items: center;
          font-size: 28px;
          color: #ee0a24;
        }
      }
    }
    .item-data-footer {
      display: flex;
      flex-direction: row;
      border-top: 1px solid #eee;
      justify-content: space-between;
      align-items: center;
      margin-top: 15px;
      padding-top: 15px;
      .item-data-footer-font-btn {
        .item-data-footer-font-btn1 {
          .nut-button--default {
            border: none !important;
          }
        }
      }

      .item-data-footer-font {
        font-size: 26px;
        color: #858a99;
      }
    }
  }
}
</style>
